<?php

/**
 * page actions.
 *
 * @package    khas
 * @subpackage page
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 3335 2007-01-23 16:19:56Z fabien $
 */
class teamActions extends sfActions
{
    public function preExecute()
    {
      ProjectConfiguration::getApplicationConfiguration('front', 'prod', false)->loadHelpers('Url');
    }

    public function executeShow(sfWebRequest $request)
    {
        ProjectConfiguration::getApplicationConfiguration('front', 'prod', false)->loadHelpers('Url');
        
        $this->seasonId = $seasonId = $request->getParameter('seasonId');
        $this->getUser()->setAttribute('activeSeasonId', $seasonId);

        $team = Doctrine::getTable('BbTeams')->findOneByTName($request->getParameter('name'));
        $this->forward404Unless($team);
        
        $this->team = $team;
        
        $breadcrumbs = array();
        $breadcrumbs[] = '<span>&raquo;</span><a href="'.url_for('team/index?seasonId='.$seasonId).'">Багууд</a>';
        $breadcrumbs[] = '<span>&raquo;</span><a href="'.url_for('team/show?seasonId='.$seasonId.'&name='.$team).'">'.$team.'</a>';
        $this->getResponse()->setSlot('breadcrumbs', $breadcrumbs);        
    }
    
    public function executeIndex(sfWebRequest $request)
    {        
        ProjectConfiguration::getApplicationConfiguration('front', 'prod', false)->loadHelpers('Url');

        $this->seasonId = $seasonId = $request->getParameter('seasonId');
        $this->getUser()->setAttribute('activeSeasonId', $seasonId);
        
      	$teams = Doctrine::getTable('BbTeams')->findBySeasonId($seasonId);
        $this->forward404Unless($teams);        
        
        $this->teams = $teams;
        $this->seasonId = $request->getParameter('seasonId');
        $breadcrumbs = array();
        $breadcrumbs[] = '<span>&raquo;</span><a href="'.url_for('team/index?seasonId='.$seasonId).'">Багууд</a>';
        $this->getResponse()->setSlot('breadcrumbs', $breadcrumbs);
    }
     
}